< previous page page_385 next page >

Page 385
In this case, the action was to return the HTML document located at the URL specified. However, if the URL was pointing to a specific text file, the actual file would be retrieved. For this example, you need to set the Protocol property to icFTP. The following code would retrieve the file and display it in the text box control, as shown in Figure 14.8:
Text1.Text = Inet1.OpenURL(ftp://ftp.microsoft.com/disclaimer.txt)
12181-0385a.gif
Figure 14.8.
Retrieving a text file by specifying the
URL and filename.
Tip
When you use the
OpenURL or Execute method, you don't need to set the Protocol property because the File Transfer control will automatically set itself to the correct protocol.

To save the information returned by the control, you can write the information directly to a file by replacing the code in the command button with the following code:
Dim strURL As String
Dim intFileNum As Integer
    IntFileNum = FreeFile()
    StrURL = http://www.microsoft.com/disclaimer.txt
    Open c:\temp\Mssource.txt for Output As IntFileNum
    Write IntFileNum, Inet1.OpenURL(strURL)
    Close IntFileNum
The OpenURL method results in synchronous communication, which means that the transfer operation occurs before any other procedures are executed. On the other hand, the Execute method results in asynchronous communication, where the transfer operation occurs independently of other procedures, allowing other code to execute while data is being received in the background. This means that you can decide how you want the data transfer to be processed simply by using the appropriate method. For the purposes of an

 
< previous page page_385 next page >

If you like this book, buy it!